public class StatusBarSeparator extends JToolBar.Separator {
    public StatusBarSeparator() {
        super();
        super.setOrientation(JSeparator.VERTICAL);
        ui = new StatusBarBasicSeparatorUI();
        // 重新設定 separator 元件寬度
        Dimension d=super.getMaximumSize();
        d.width = 22;
        setMaximumSize(d);
        // nimbus 需要再設定 preferredSize
        d=super.getPreferredSize();
        d.width = 22;
        setPreferredSize(d);
    }
    public void setUI(SeparatorUI ui) {
        super.setUI(this.ui);
    }
    public SeparatorUI getUI() {
        return (SeparatorUI)ui;
    }
    /**
     * StatusBar separator UI
     */
    public class StatusBarBasicSeparatorUI extends BasicSeparatorUI {
        public void paint( Graphics g, JComponent c ) {
            // 計算方位
            Dimension d = c.getSize();
            int left = (d.width-1) / 2;

            // 畫線
            g.setColor( c.getForeground() );
            g.drawLine( left, 0, left, d.height );
            g.setColor( c.getBackground() );
            g.drawLine( left+1, 0, left+1, d.height );
        }
    }
}
